{include file="public/header" /}
    <style>
        body {
            background-color: #ffffff;
        }
        .layui-form-label{
            width: 120px;
        }
        .layui-input-block {
            margin-left: 150px;
        }
    </style>
</head>
<body>

<div class="layui-tab">
    <ul class="layui-tab-title">
        <li >
            <a target="_self" class="current" href="/admin/setting/system">
                网站设置
            </a>
        </li>

        <li>
            <a target="_self" class="current" href="/admin/setting/upload">
                存储配置
            </a>
        </li>
        <li class="layui-this">
            <a target="_self" class="current" href="/admin/setting/sms">
                短信配置
            </a>
        </li>

        <li>
            <a target="_self" class="current" href="/admin/setting/service">
                客服信息
            </a>
        </li>
    </ul>
</div>

<form class="layui-form" action="">
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this">短信配置</li>
            <li>线路配置</li>
        </ul>
        <div class="layui-tab-content" style="height: 100px;">
            <div class="layui-tab-item layui-show">
                <div class="layui-form-item">
                    <label class="layui-form-label">服务商</label>
                    <div class="layui-input-block">
                        <select name="bxkj_sms[platform]" id="platform" lay-verify="required" >
                            <option value="aliyun">阿里云通信</option>
                            <option value="tencloud">腾讯云通信</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">验证码有效期</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[sms_code_expire]"  class="layui-input" value="{$_info.bxkj_sms.sms_code_expire}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">发送时间间隔</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[sms_code_limit]"  class="layui-input" value="{$_info.bxkj_sms.sms_code_limit}">
                    </div>
                </div>
            </div>

            <div class="layui-tab-item">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                    <legend>区域线路</legend>
                </fieldset>
                <div class="layui-form-item">
                    <label class="layui-form-label">应用Access_id</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[regional][access_id]"  class="layui-input" value="{$_info.bxkj_sms.regional.access_id}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应用Access_secret</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[regional][access_secret]"  class="layui-input" value="{$_info.bxkj_sms.regional.access_secret}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应用Region</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[regional][region]"  class="layui-input" value="{$_info.bxkj_sms.regional.region}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应用Endpoint_name</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[regional][endpoint_name]"  class="layui-input" value="{$_info.bxkj_sms.regional.endpoint_name}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应用Sign_name</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[regional][sign_name]"  class="layui-input" value="{$_info.bxkj_sms.regional.sign_name}">
                    </div>
                </div>


                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                    <legend>国际线路</legend>
                </fieldset>

                <div class="layui-form-item">
                    <label class="layui-form-label">应用Access_id</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[global][access_id]"  class="layui-input" value="{$_info.bxkj_sms.global.access_id}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应用Access_secret</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[global][access_secret]"  class="layui-input" value="{$_info.bxkj_sms.global.access_secret}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应用Region</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[global][region]"  class="layui-input" value="{$_info.bxkj_sms.global.region}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应用Endpoint_name</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[global][endpoint_name]"  class="layui-input" value="{$_info.bxkj_sms.global.endpoint_name}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应用Sign_name</label>
                    <div class="layui-input-block">
                        <input type="text" name="bxkj_sms[global][sign_name]"  class="layui-input" value="{$_info.bxkj_sms.global.sign_name}">
                    </div>
                </div>

            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="saveBtn">立即提交</button>
        </div>
    </div>

</form>

</body>

{include file="public/footer" /}
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url: "{:url('sms')}",
                type: 'post',
                dataType: 'json',
                data: data.field,
                timeout: 2000,
                success: function (data1) {
                    if (data1.code == 0) {
                        layer.msg(data1.msg)
                        setTimeout(function () {
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                        }, 1000);
                    } else {
                        layer.msg(data1.msg)
                    }
                },
                error: function () {
                    layer.msg("添加失败")
                }
            })
            return false;
        });

        var platform = "{:isset($_info.bxkj_sms.platform) ? $_info.bxkj_sms.platform : ''}";
        $('#platform').find("option[value="+platform+"]").attr("selected",true);
        form.render('select')
    });
</script>

</html>